package com.block.product.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.product.enums.UnionTypeEnum;
import com.block.product.service.IUnionProductService;
import com.block.product.service.union.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 联登类型工具类
 */
public class UnionTypeFactory {

    private static Map<String, Class<? extends IUnionProductService>> serviceMap = new HashMap<>();

    static {

        serviceMap.put(UnionTypeEnum.DEFAULT.getValue(), DefaultProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.XINYEBANG.getValue(), XinYeBangProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.BXTODAY.getValue(), BXTodayProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.DINGDINGBNAG.getValue(), DDBProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.QIDAI.getValue(), QiDaiProductServiceImpl.class);

        serviceMap.put(UnionTypeEnum.SUISHIDAI.getValue(), SuiShiDaiProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.HAOHUITUI.getValue(), HaoHuiTuiProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.LEYOUHUA.getValue(), LeYouHuaProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.CHENGYI.getValue(), ChengYiProductServiceImpl.class);
        serviceMap.put(UnionTypeEnum.LINGYONGGOU.getValue(), LingYongGouProductServiceImpl.class);
    }

    public static IUnionProductService getService(String proType){
        if (serviceMap.containsKey(proType)){
            Class<? extends  IUnionProductService> aClass = serviceMap.get(proType);
            IUnionProductService beanService = ApplicationContextUtil.getBean(aClass);
            return beanService;
        }
        return null;
    }

}
